home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Mac Game Programming Gurus / TricksOfTheMacGameProgrammingGurus.iso / More Source / Libraries / VideoToolbox 95.04.18 / VideoToolboxSources / Log2L.c < prev    next >
Text File  |  1993-02-23  |  347b  |  20 lines

  1. /*
  2. Log2L.c
  3. HISTORY:
  4. 12/3/91 dgp changed zero argument return from -1 to LONG_MIN.
  5. */
  6. #include "VideoToolbox.h"
  7.  
  8. long Log2L(unsigned long j)
  9. // returns the integer part of log2(j)
  10. {
  11.     long L=-1;
  12.     register unsigned long i=j;    // Because THINK C won't put arguments into registers
  13.  
  14.     if(i==0)return LONG_MIN;
  15.     while(i>0){
  16.         i>>=1;
  17.         L++;
  18.     }
  19.     return L;
  20. }